﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI.Adapters;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.Publishing.WebControls;

namespace Macaw.Moss2007.PublishingScheduleFieldControlAdapterSolution
{
    public class PublishingScheduleFieldControlAdapter : ControlAdapter
    {

        protected override void CreateChildControls()
        {
            base.CreateChildControls();
            BaseFieldControl schedulerFieldControl = Control as BaseFieldControl;
            if (schedulerFieldControl != null && schedulerFieldControl.FieldName.Equals("PublishingExpirationDate"))
            {
                PublishingScheduleControl scheduler = schedulerFieldControl.Controls[0] as PublishingScheduleControl;
                if (scheduler != null)
                {
                    scheduler.UseAsEndDate = true;
                }
            }
        }
    }
}
